#!/usr/bin/env python
#coding=utf8

import unittest
from human import Player
from human import Enemy

class TestSkill(unittest.TestCase):
    '''经验系统的测试用例'''
    def setUp(self):
        self.ppl1 = Player(mhp=10,hp=3)
        self.ppl2 = Player(mhp=10,hp=3)
        self.ppl3 = Player(mhp=10,hp=3)
        self.ppl4 = Player(mhp=10,hp=3,exp=1000)
        self.enemy1 = Enemy(mhp=8,hp=8)
        self.enemy2 = Enemy(mhp=8,hp=8)
        self.enemy3 = Enemy(mhp=8,hp=8)
        self.enemy4 = Enemy(mhp=8,hp=8)



        
    def test_att(self):
        '''测试攻击经验'''
        self.ppl1.realAttack(self.enemy1)
        self.assertEqual(self.ppl1.exp,20)
    
    def test_ko(self):
        '''测试KO经验'''
        self.enemy2.hp=0
        self.ppl2.realAttack(self.enemy2)
        self.assertEqual(self.ppl2.exp,50)
        
    def test_upgrade(self):
        '''测试升级'''
        self.ppl3.exp = 95
        print self.ppl3.exp
        print self.ppl3.heroLV
        self.ppl3.realAttack(self.enemy3)
        print self.ppl3.exp
        print self.ppl3.heroLV
        self.assertEqual(self.ppl3.heroLV,2)
        self.assertEqual(self.ppl3.exp,115)
    def test_exp (self):
        print 'your lv is',self.ppl4.heroLV
        for i in range(0,5):
        	self.ppl4.realAttack(self.enemy4)
        print 'your newLV is',self.ppl4.heroLV
        print 'your exp is',self.ppl4.exp
        self.assertEqual(self.ppl4.heroLV,13)
        self.assertEqual(self.ppl4.exp,1220)
    	

if __name__ == '__main__':
    unittest.main()
